package com.ympc.service.impl;

import com.ympc.mapper.ClassMapper;
import com.ympc.pojo.Class;
import com.ympc.service.ClassService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassServiceImpl implements ClassService {
    
    @Resource
    private ClassMapper classMapper;
    
    @Override
    public List<Class> getClassesByTeacherId(Integer teacherId) {
        return classMapper.findByTeacherId(teacherId);
    }
    
    @Override
    public Class getClassById(Integer id) {
        return classMapper.findById(id);
    }
    
    @Override
    public List<Class> getAllClasses() {
        return classMapper.findAll();
    }
    
    @Override
    public List<Class> getClassesByClassName(String className) {
        return classMapper.findByClassName(className);
    }
    
    @Override
    public boolean addClass(Class clazz) {
        return classMapper.insertClass(clazz) > 0;
    }
    
    @Override
    public boolean updateClass(Class clazz) {
        return classMapper.updateClass(clazz) > 0;
    }
    
    @Override
    public boolean deleteClass(Integer id) {
        return classMapper.deleteClass(id) > 0;
    }
}

